119. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2023-07-12 04:42:39 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

119.1 Files compared

#LocationFileLast Modified
1Porto v4.0.5/Theme Files/Porto Theme/app/code/Smartwave/Filterproducts/Block/HomeBestsellersList.php2020-08-17 03:41:58 +0000
2Porto v4.0.6/Theme Files/Porto Theme/app/code/Smartwave/Filterproducts/Block/HomeBestsellersList.php2023-06-13 09:00:04 +0000

119.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged2180
Changed12
Inserted00
Removed00

119.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

119.4 Active regular expressions

No regular expressions were active.

119.5 Comparison detail

1 <?php 1 <?php
2  2 
3 namespace Smartwave\Filterproducts\Block\Home; 3 namespace Smartwave\Filterproducts\Block\Home;
4  4 
5 use Magento\Catalog\Api\CategoryRepositoryInterface; 5 use Magento\Catalog\Api\CategoryRepositoryInterface;
6  6 
7 class BestsellersList extends \Magento\Catalog\Block\Product\ListProduct { 7 class BestsellersList extends \Magento\Catalog\Block\Product\ListProduct {
8  8 
9     protected $_collection; 9     protected $_collection;
10  10 
11     protected $categoryRepository; 11     protected $categoryRepository;
12  12 
13     protected $_resource; 13     protected $_resource;
14  14 
15     public function __construct( 15     public function __construct(
16             \Magento\Catalog\Block\Product\Context $context, 16             \Magento\Catalog\Block\Product\Context $context,
17             \Magento\Framework\Data\Helper\PostHelper $postDataHelper, 17             \Magento\Framework\Data\Helper\PostHelper $postDataHelper,
18             \Magento\Catalog\Model\Layer\Resolver $layerResolver, 18             \Magento\Catalog\Model\Layer\Resolver $layerResolver,
19             CategoryRepositoryInterface $categoryRepository, 19             CategoryRepositoryInterface $categoryRepository,
20             \Magento\Framework\Url\Helper\Data $urlHelper, 20             \Magento\Framework\Url\Helper\Data $urlHelper,
21             \Magento\Catalog\Model\ResourceModel\Product\Collection $collection, 21             \Magento\Catalog\Model\ResourceModel\Product\Collection $collection,
22             \Magento\Framework\App\ResourceConnection $resource, 22             \Magento\Framework\App\ResourceConnection $resource,
23             array $data = [] 23             array $data = []
24     ) {
 24     ) { 
25         $this->categoryRepository = $categoryRepository; 25         $this->categoryRepository = $categoryRepository;
26         $this->_collection = $collection; 26         $this->_collection = $collection;
27         $this->_resource = $resource; 27         $this->_resource = $resource;
28  28 
29         parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data); 29         parent::__construct($context, $postDataHelper, $layerResolver, $categoryRepository, $urlHelper, $data);
30     } 30     }
31  31 
32     protected function _getProductCollection() { 32     protected function _getProductCollection() {
33         return $this->getProducts(); 33         return $this->getProducts();
34     } 34     }
35  35 
36     public function getProducts() { 36     public function getProducts() {
37         $count = $this->getProductCount(); 37         $count = $this->getProductCount();
38         $category_id = $this->getData("category_id"); 38         $category_id = $this->getData("category_id");
39         $collection = clone $this->_collection; 39         $collection = clone $this->_collection;
40         $collection->clear()->getSelect()->reset(\Magento\Framework\DB\Select::WHERE)->reset(\Magento\Framework\DB\Select::ORDER)->reset(\Magento\Framework\DB\Select::LIMIT_COUNT)->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET)->reset(\Magento\Framework\DB\Select::GROUP)->reset(\Magento\Framework\DB\Select::COLUMNS)->reset('from'); 40         $collection->clear()->getSelect()->reset(\Magento\Framework\DB\Select::WHERE)->reset(\Magento\Framework\DB\Select::ORDER)->reset(\Magento\Framework\DB\Select::LIMIT_COUNT)->reset(\Magento\Framework\DB\Select::LIMIT_OFFSET)->reset(\Magento\Framework\DB\Select::GROUP)->reset(\Magento\Framework\DB\Select::COLUMNS)->reset('from');
41         $collection->getSelect()->join(['e' => $collection->getTable('catalog_product_entity')],''); 41         $collection->getSelect()->join(['e' => $collection->getTable('catalog_product_entity')],'');
42  42 
43         if(!$category_id) { 43         if(!$category_id) {
44             $category_id = $this->_storeManager->getStore()->getRootCategoryId(); 44             $category_id = $this->_storeManager->getStore()->getRootCategoryId();
45         } 45         }
46         $category = $this->categoryRepository->get($category_id); 46         $category = $this->categoryRepository->get($category_id);
47         if(isset($category) && $category) { 47         if(isset($category) && $category) {
48             $collection->addMinimalPrice() 48             $collection->addMinimalPrice()
49                 ->addFinalPrice() 49                 ->addFinalPrice()
50                 ->addTaxPercents() 50                 ->addTaxPercents()
51                 ->addAttributeToSelect('name') 51                 ->addAttributeToSelect('name')
52                 ->addAttributeToSelect('image') 52                 ->addAttributeToSelect('image')
53                 ->addAttributeToSelect('small_image') 53                 ->addAttributeToSelect('small_image')
54                 ->addAttributeToSelect('thumbnail') 54                 ->addAttributeToSelect('thumbnail')
55                 ->addAttributeToSelect($this->_catalogConfig->getProductAttributes()) 55                 ->addAttributeToSelect($this->_catalogConfig->getProductAttributes())
56                 ->addUrlRewrite() 56                 ->addUrlRewrite()
57                 ->addCategoryFilter($category); 57                 ->addCategoryFilter($category);
58         } else { 58         } else {
59             $collection->addMinimalPrice() 59             $collection->addMinimalPrice()
60                 ->addFinalPrice() 60                 ->addFinalPrice()
61                 ->addTaxPercents() 61                 ->addTaxPercents()
62                 ->addAttributeToSelect('name') 62                 ->addAttributeToSelect('name')
63                 ->addAttributeToSelect('image') 63                 ->addAttributeToSelect('image')
64                 ->addAttributeToSelect('small_image') 64                 ->addAttributeToSelect('small_image')
65                 ->addAttributeToSelect('thumbnail') 65                 ->addAttributeToSelect('thumbnail')
66                 ->addAttributeToSelect($this->_catalogConfig->getProductAttributes()) 66                 ->addAttributeToSelect($this->_catalogConfig->getProductAttributes())
67                 ->addUrlRewrite(); 67                 ->addUrlRewrite();
68         } 68         }
69  69 
70         $collection->getSelect() 70         $collection->getSelect()
71             ->joinLeft(['soi' => $collection->getTable('sales_order_item')], 'soi.product_id = e.entity_id', ['SUM(soi.qty_ordered) AS ordered_qty']) 71             ->joinLeft(['soi' => $collection->getTable('sales_order_item')], 'soi.product_id = e.entity_id', ['SUM(soi.qty_ordered) AS ordered_qty'])
72             ->join(['order' => $collection->getTable('sales_order')], "order.entity_id = soi.order_id",['order.state']) 72             ->join(['order' => $collection->getTable('sales_order')], "order.entity_id = soi.order_id",['order.state'])
73             ->where("order.state <> 'canceled' and soi.parent_item_id IS NULL AND soi.product_id IS NOT NULL") 73             ->where("order.state <> 'canceled' and soi.parent_item_id IS NULL AND soi.product_id IS NOT NULL")
74             ->group('soi.product_id') 74             ->group('soi.product_id')
75             ->order('ordered_qty DESC') 75             ->order('ordered_qty DESC')
76             ->limit($count); 76             ->limit($count);
77  77 
78         return $collection; 78         return $collection;
79     } 79     }
80  80 
81     public function getLoadedProductCollection() { 81     public function getLoadedProductCollection() {
82         return $this->getProducts(); 82         return $this->getProducts();
83     } 83     }
84  84 
85     public function getProductCount() { 85     public function getProductCount() {
86         $limit = $this->getData("product_count"); 86         $limit = $this->getData("product_count");
87         if(!$limit) 87         if(!$limit)
88             $limit = 10; 88             $limit = 10;
89         return $limit; 89         return $limit;
90     } 90     }
91 } 91 }